#import "ZJMessageApprovelViewController.h"

@interface ZJMessageApprovelViewController ()

//@property (nonatomic, strong) UILabel *titleLabel;
//@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) UIView *cardView;

@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UILabel *cardTitleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIButton *approvalButton;

@end

@implementation ZJMessageApprovelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor backgroundGrayColor];
    [self setupUI];
    self.title =  @"审批消息";
}

- (void)setupUI {
    // 1. 先确保视图控制器有导航栏
//    if (!self.navigationController) {
//        self.navigationController = [[UINavigationController alloc] initWithRootViewController:self];
//    }
    
    // 2. 返回按钮
//    self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.backButton setImage:[UIImage imageNamed:@"back_icon"] forState:UIControlStateNormal];
//    [self.backButton addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    // 3. 标题
//    self.titleLabel = [[UILabel alloc] init];
//    self.titleLabel.text = @"审批消息";
//    self.titleLabel.textAlignment = NSTextAlignmentCenter;
//    self.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium];
    
    // 4. 卡片视图
    self.cardView = [[UIView alloc] init];
    self.cardView.backgroundColor = [UIColor whiteColor];
    self.cardView.layer.cornerRadius = 8;
    // 添加阴影效果
    self.cardView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.cardView.layer.shadowOffset = CGSizeMake(0, 2);
    self.cardView.layer.shadowOpacity = 0.1;
    self.cardView.layer.shadowRadius = 4;
    
    // 5. 卡片标题
    self.cardTitleLabel = [[UILabel alloc] init];
    self.cardTitleLabel.text = @"人员通行证审批";
    self.contentLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
    self.contentLabel.textColor = [UIColor colorWithHexString:@"181818"];
    
    // 6. 内容
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.text = @"张三申请\"人员通行证申请\"，请及时审核";
    self.contentLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.contentLabel.textColor = [UIColor colorWithHexString:@"333333"];
    self.contentLabel.numberOfLines = 0;
    
    
   self.lineView = [[UIView alloc] init];
   self. lineView.backgroundColor = [UIColor colorWithHexString:@"#E4E4E4"];

    
    // 7. 审批按钮
    self.approvalButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.approvalButton setTitle:@"进入审批" forState:UIControlStateNormal];
    [self.approvalButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.approvalButton.backgroundColor = [UIColor mainColor];
    self.approvalButton.layer.cornerRadius = 4;
    [self.approvalButton.titleLabel setFont:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium]];
    [self.approvalButton addTarget:self action:@selector(approvalButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    // 8. 添加视图层级
//    [self.view addSubview:self.backButton];
//    [self.view addSubview:self.titleLabel];
    [self.view addSubview:self.cardView];
    [self.cardView addSubview:self.cardTitleLabel];
    [self.cardView addSubview:self.contentLabel];
    [self.cardView addSubview:self.approvalButton];
    [self.cardView addSubview:self.lineView];
    
    // 9. 设置约束
    [self setupConstraints];
}

- (void)setupConstraints {
  
    

    
    // 卡片视图约束
    [self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(12);
        make.right.equalTo(self.view).offset(-12);
//        make.bottom.equalTo(self.view).offset(-12);
        make.top.equalTo(self.view).offset(20 + StatusBarHeight);
    }];
    
    // 卡片标题约束
    [self.cardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cardView).offset(10);
        make.top.equalTo(self.cardView).offset(12);
        make.right.equalTo(self.cardView).offset(-10);
    }];
    
    // 内容约束
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cardView).offset(10);
        make.right.equalTo(self.cardView).offset(-10);
        make.top.equalTo(self.cardTitleLabel.mas_bottom).offset(10);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self.cardView).offset(10);
        make.right.equalTo(self.cardView).offset(-10);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(38);
    }];
    
    // 审批按钮约束
    [self.approvalButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.cardView).offset(-10);
        make.top.equalTo(self.lineView.mas_bottom).offset(12);
        make.bottom.equalTo(self.cardView).offset(-12);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(28);
    }];
}

- (void)approvalButtonClicked {
    // 处理审批按钮点击事件
}

@end
